core: Fix "cat" crashing when it should have returned ENOENT
authorColin Walters <walters@verbum.org>
Wed, 7 Mar 2012 15:25:26 +0000 (10:25 -0500)
committerColin Walters <walters@verbum.org>
Thu, 8 Mar 2012 17:10:58 +0000 (12:10 -0500)
src/libostree/ostree-repo-file.c
src/ostree/ot-builtin-cat.c

index 24ec230130b45ff14245e75b564f3a1a1b3aaae3..9cc7b82389c3378c42b3ca529ab8725dbdf1326b 100644 (file)
@@ -992,6 +992,9 @@ ostree_repo_file_read (GFile         *file,
   OstreeRepoFile *self = OSTREE_REPO_FILE (file);
   const char *checksum;
 
+  if (!ostree_repo_file_ensure_resolved (self, error))
+    goto out;
+
   if (self->tree_contents)
     {
       g_set_error_literal (error, G_IO_ERROR,
index 0096f3a647ce61616f0defb9641c54be88fb9ce1..ff04e8e7aae5d4fd26cf77f354df084b74e7c1a3 100644 (file)
@@ -41,9 +41,6 @@ cat_one_file (GFile         *f,
   gboolean ret = FALSE;
   GInputStream *in = NULL;
   
-  if (!ostree_repo_file_ensure_resolved ((OstreeRepoFile*)f, NULL))
-    g_assert_not_reached ();
-
   in = (GInputStream*)g_file_read (f, cancellable, error);
   if (!in)
     goto out;